home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / x / gui / xfract.lha / xfract / f3dbm.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1990-06-27  |  45.7 KB  |  1,540 lines

  1. #! /bin/sh
  2. # This is a shell archive. To extract the files type 'sh file'
  3. # This archive created on Thu Jun 21 16:37:30 WET DST 1990\n
  4. export PATH; PATH=/bin:$PATH
  5. echo 'Shar: extracting 'README' ( 4338 characters)'
  6. if test -f 'README'
  7. then
  8.     echo "Shar: will not overwrite existing file 'README'"
  9. else
  10.     cat << \SHAR_EOF > 'README'
  11. FRACTALS - July 1989.
  12. --------- -----------
  13.  
  14. Author:        Paul Sharpe @ DEC, Reading, England.
  15. Inspiration:    Title:        "The Science Of Fractal Images."
  16.         Editors:    Heinz-Otto Peitgen, Dietmar Saupe
  17.         Published:    Springer-Verlag
  18.  
  19. >>> Copyright (c) Digital Equipment Corporation 1990  All rights reserved.
  20. >>> Copyright is claimed in the computer program and user interface thereof.
  21.  
  22. >>> Digital Equipment Corporation cannot accept any responsibility for
  23. >>> use, misuse, or abuse of this software.
  24.  
  25. >>> The code is provided as-is. No guarantee is made to provide support or
  26. >>> maintenance.
  27. >>> This said, the code may be used in any way, on the provisos:
  28. >>> 1 - The author and the authors company can not accept any responsibilty
  29. >>>     for the use/misuse/abuse of the software.
  30. >>> 2 - The credits/copyrights at the top of the files remain.
  31. >>> Any suggestions/improvements/bug-reports will be at least read.
  32.  
  33. This code was written under Ultrix(c) on a Vaxstation II GPX, with 8-plane
  34. colour, using DECwindows. It should work on 'any' UNIX(c), with X11
  35. derivatives and with 1 or more colour planes...
  36.  
  37. It has been tested on a DECuVax II GPX (8-plane), a DS3100 (8-plane)
  38. and a Sun 3/50 (1-plane)
  39. It requires the X11 library, though probably not necessarily release 3.
  40.  
  41. To compile, edit the Makefile and configure the compiler options: in
  42. particular, change the paths to find the bitmaps for the icon and the
  43. background.
  44. Then just type 'make'.
  45.  
  46.  
  47.  
  48. Fractal mountains in 3D, by brownian motion.
  49. --------------------------------------------
  50.  
  51. It was mainly written with a colour capacity in mind, but allows the colours
  52. on the command line to be set for monochrome dispays:
  53.  
  54. e.g. for monochrome: xmntn -ba black -mn black -se black)
  55.  
  56. Use 'xmntn -help' for a full list of options.
  57.  
  58. There is a simple interaction to allow new generations of mountain data without
  59. having to quit and restart: simply click any mouse button in the pointer window
  60. at the point along the scale for the dimension. The scale is graduated at the
  61. integer values 1.00 and 2.00, and the scale allows for values entered up to
  62. 3.00. Clicking on the 'New Mountains' window will cause new data to be
  63. generated and the mountains drawn. On a lowly GPX, this takes 30 seconds or
  64. so for each phase. On a MIPS box, its INSTANT!
  65.  
  66. There is an alternative perspective to the mountains shown by the executable
  67. 'xlmntn'. This attempts to bring the viewer down to the level of the
  68. mountains. It takes many of the same options, but also allows for the distance
  69. of the observer to be changed.
  70.  
  71. There are lots of arguments, but 'sensible' defaults are provided that allow
  72. you to just run the program. Most options are self-explanatory: others are
  73. not really to be changed. The general idea is to just play with them!
  74.  
  75. xmntn|xlmntn
  76.     -display display-string    (default: "")
  77.     -foreground colour    (default: white)
  78.     -background colour    (default: red)
  79.     -textfg colour        (default: white)
  80.     -textbg colour         (default: blue)
  81.     -seacolour  colour    (default: blue)
  82.     -mntncolour colour    (default: forestgreen)
  83.     -numcolours integer    (default: 50)
  84.     -colour r,g,b        (default: g)        <i.e. any of r,g,b>
  85.     -fontfile fontfile    (default: )
  86.     -H double        (default: 0.9)
  87.     -scale double        (default: 2.5)
  88.     -level integer        (default: 7)
  89.  
  90.     -mntndistance integer    (default: 100)        <xlmntn only>
  91.     -scrndistance integer    (default: 500)        <xlmntn only>
  92.     -height integer        (default: 120)        <xlmntn only>
  93.  
  94.     -xscale integer        (default: 4)        <xmntn only>
  95.     -yscale integer        (default: 2)        <xmntn only>
  96.  
  97. Restrictions/Things To Do:
  98. --------------------------
  99. o Each program, when using full colour, installs a local colourmap for its
  100. main window: this has the 'disturbing' effect of changing the colours of
  101. existing applications. This is only for the lifetime of these fractal
  102. programs, and only while they are currently in focus... This should
  103. negociate/cooperate with the window-manager...
  104.  
  105. o Small level numbers (<4) cause there to be not enough width for the
  106. 'buttons' and 'labels', which then overlap. They should try harder at
  107. fitting, or should be re-sized, or re-prioritised... Maybe the font
  108. should be made smaller...
  109.  
  110. o There should be a visible indication of when any of the 'buttons' are
  111. clicked upon...
  112.  
  113. o Better behaviour on having areas exposed: redrawing the entire region
  114. is not a good idea on slow systems.
  115.  
  116. Any problems to sharpe@wessex.co.uk
  117. SHAR_EOF
  118. if test 4338 -ne `wc -c < 'README'`
  119. then
  120.     echo 'Shar: error transmitting 'README' (should have been  4338 charcaters)'
  121. fi
  122. fi
  123. echo 'Shar: extracting 'Makefile' ( 1223 characters)'
  124. if test -f 'Makefile'
  125. then
  126.     echo "Shar: will not overwrite existing file 'Makefile'"
  127. else
  128.     cat << \SHAR_EOF > 'Makefile'
  129. ###############################################################################
  130. #*
  131. #*   Copyright (c) Digital Equipment Corporation 1990  All rights reserved.
  132. #*   Copyright is claimed in the computer program and user interface thereof.
  133. #*
  134. #*   Digital Equipment Corporation cannot accept any responsibility for
  135. #*   use, misuse, or abuse of this software.
  136. #*
  137. ###############################################################################
  138.  
  139. ICONFILE= -DICONFILE="\"/eueg/valmar1/pjs/src/MNTNS/mntn.btm\""
  140. BCKGFILE= -DBCKGRND="\"/eueg/valmar1/pjs/src/MNTNS/bg.btm\""
  141. CFLAGS= -O ${ICONFILE} ${BCKGFILE}
  142.  
  143. STRIP=touch
  144.  
  145. HFILES= xpt.h xlmntn.h xmntn.h
  146.  
  147. CMNO=    xpt.o gen_mntndata.o cmn_mntncode.o
  148. CMNC=    xpt.c gen_mntndata.c cmn_mntncode.c
  149. XLO=    xlmntn.o
  150. XLC=    xlmntn.c
  151. XO=    xmntn.o
  152. XC=    xmntn.c
  153.  
  154. BTMS=    bg.btm mntn.btm
  155.  
  156. SHAR= xmntns.sh
  157.  
  158. PROGS = xmntn xlmntn
  159.  
  160. X11=    -lX11
  161.  
  162. all:    ${PROGS}
  163.  
  164. xmntn:    ${CMNO} ${XO}
  165.     cc -O -o $@ ${CMNO} ${XO} ${X11} -lm
  166.     @${STRIP} $@
  167.     @ls -l $@
  168.  
  169. xlmntn:    ${CMNO} ${XLO}
  170.     cc -O -o $@ ${CMNO} ${XLO} ${X11} -lm
  171.     @${STRIP} $@
  172.     @ls -l $@
  173.  
  174. xpt.o:        xpt.h
  175. xmntn.o:    xmntn.h
  176. xlmntn.o:    xlmntn.h
  177.  
  178. clean:
  179.     rm -f *.o ${PROGS} core
  180.  
  181. shar:
  182.     shar README Makefile ${HFILES} ${CMNC} ${XC} ${XLC} ${BTMS} > ${SHAR}
  183.     @ls -l ${SHAR}
  184. SHAR_EOF
  185. if test 1223 -ne `wc -c < 'Makefile'`
  186. then
  187.     echo 'Shar: error transmitting 'Makefile' (should have been  1223 charcaters)'
  188. fi
  189. fi
  190. echo 'Shar: extracting 'xpt.h' ( 1211 characters)'
  191. if test -f 'xpt.h'
  192. then
  193.     echo "Shar: will not overwrite existing file 'xpt.h'"
  194. else
  195.     cat << \SHAR_EOF > 'xpt.h'
  196. /*****************************************************************************
  197. /* FILE         : xpt.h
  198. /* DATE         : August 25, 1989.
  199. /* AUTHOR       : Paul Sharpe @ DEC, Reading (OSCR-Europe).
  200. /* FUNCTION     : header file to 'toolkit' of common functions.
  201. /*
  202. /*   Copyright (c) Digital Equipment Corporation 1990  All rights reserved.
  203. /*   Copyright is claimed in the computer program and user interface thereof.
  204. /*
  205. /*   Digital Equipment Corporation cannot accept any responsibility for
  206. /*   use, misuse, or abuse of this software.
  207. /*
  208. /*****************************************************************************/
  209.  
  210. #define DEFDSPLY        "unix:0.0"
  211.  
  212. #define DEBUG(x)        {printf x; fflush(stdout);}
  213. #define ROOTWNDW(d)    RootWindow((d),DefaultScreen((d)))
  214. #define DEFDEPTH(d)    DefaultDepth((d),DefaultScreen((d)));
  215.  
  216. #define TRUE    1
  217. #define ON    1
  218. #define YES    1
  219. #define    SET    1
  220.  
  221. #define    FALSE    0
  222. #define OFF    0
  223. #define NO    0
  224. #define UNSET    0
  225.  
  226. #define ARGS(X)    (args[(X)].valstr)
  227. struct opts {
  228.     char        flagstr[32];    /* Full argument flag string */
  229.     char    aflagstr[8];    /* Abbreviated argument flag string */
  230.     char    *valstr;    /* Argument command line value. */
  231.     char    *usage;        /* Usage descriptor. */
  232. };
  233. SHAR_EOF
  234. if test 1211 -ne `wc -c < 'xpt.h'`
  235. then
  236.     echo 'Shar: error transmitting 'xpt.h' (should have been  1211 charcaters)'
  237. fi
  238. fi
  239. echo 'Shar: extracting 'xlmntn.h' ( 2546 characters)'
  240. if test -f 'xlmntn.h'
  241. then
  242.     echo "Shar: will not overwrite existing file 'xlmntn.h'"
  243. else
  244.     cat << \SHAR_EOF > 'xlmntn.h'
  245. /*****************************************************************************
  246. /* FILE        : xlmntn.h
  247. /* AUTHOR    : Paul Sharpe @ DEC (OSCR-Europe, Reading, England).
  248. /* DATE        : July 20, 1989
  249. /* FUNCTION    : X-windows Fractal Brownian-Motion mountains.
  250. /* INSPIRATION    : 'The Science Of Fractal Images.'
  251. /*
  252. /*   Copyright (c) Digital Equipment Corporation 1990  All rights reserved.
  253. /*   Copyright is claimed in the computer program and user interface thereof.
  254. /*
  255. /*   Digital Equipment Corporation cannot accept any responsibility for
  256. /*   use, misuse, or abuse of this software.
  257. /*
  258. /*****************************************************************************/
  259.  
  260. /*****************************************/
  261. /* CONFIGURE THIS SECTION AS REQUIRED... */
  262. /*****************************************/
  263.  
  264. #define FNTFILE         "fg-18"
  265. #define PROGTITLE    "Xlmntn"
  266.  
  267. /* The argument list processing structure... */
  268. #define NUMARGS    16
  269. struct opts    args[NUMARGS] = {
  270. {"-display",    "-ds", "",        "-display serverstring"},
  271. {"-foreground", "-fg", "white",        "-foreground colour"},
  272. {"-background", "-bg", "red",        "-background colour"},
  273. {"-textfg",      "-tf", "white",        "-textfg  colour"},
  274. {"-textbg",      "-tb", "blue",        "-textbg  colour"},
  275. {"-seacolour",  "-sc", "blue",        "-seacolour  colour"},
  276. {"-mntncolour", "-mc", "forestgreen",    "-mntncolour colour"},
  277. {"-numcolours", "-nc", "50",        "-numcolours integer"},
  278. {"-colours",    "-cl", "g",        "-colours r|g|b"},
  279. {"-fontfile",    "-fn", FNTFILE,        "-fontfile fontfile"},
  280. {"-H",        "-hg", "0.9",        "-H double"},
  281. {"-scale",     "-sl", "2.5",        "-scale double"},
  282. {"-level",    "-lv", "7",        "-level integer[3-~8]"},
  283. {"-mntndistance","-md", "100",        "-mntndistance integer"},
  284. {"-scrndistance","-sd", "500",        "-scrndistance integer"},
  285. {"-height",    "-ht", "120",        "-height  integer"},
  286. };
  287.  
  288. /*****************************************/
  289. /* END OF CONFIGURATION SECTION...       */
  290. /*****************************************/
  291.  
  292. #define PNTS(i,px,py)    {pnts[(i)].x=(px);pnts[(i)].y=(py);}
  293. #define PIXELX(x,y)    ((((x)-square/2)*scrndist)/(mntndist+(y))+(screenwidth/2))
  294. #define    PIXELY(x,y,e)    (zeroy - ((e)-obsheight)*scrndist/(mntndist+(y)))
  295.  
  296. char    *progtitle = PROGTITLE;
  297. char    *bckgrnd   = BCKGRND;
  298. char    *iconfile  = ICONFILE;
  299.  
  300. int     zeroy;
  301. int     obsheight;
  302. int    scrndist, mntndist;
  303.  
  304. extern int    screenwidth, screenheight;
  305. extern int    square, yscale;
  306. extern struct mntn {
  307.     double      **elevs;
  308.     int         **px;
  309.     int         **py;
  310. } mntndata;
  311. extern int    basey;
  312. extern Window    wndw;
  313. extern GC    maingc, seagc;
  314. extern Display    *dsply;
  315. extern long    mc;
  316. SHAR_EOF
  317. if test 2546 -ne `wc -c < 'xlmntn.h'`
  318. then
  319.     echo 'Shar: error transmitting 'xlmntn.h' (should have been  2546 charcaters)'
  320. fi
  321. fi
  322. echo 'Shar: extracting 'xmntn.h' ( 2490 characters)'
  323. if test -f 'xmntn.h'
  324. then
  325.     echo "Shar: will not overwrite existing file 'xmntn.h'"
  326. else
  327.     cat << \SHAR_EOF > 'xmntn.h'
  328. /*****************************************************************************
  329. /* FILE        : xmntn.h
  330. /* AUTHOR    : Paul Sharpe @ DEC (OSCR-Europe, Reading, England).
  331. /* DATE        : July 20, 1989
  332. /* FUNCTION    : X-windows Fractal Brownian-Motion mountains.
  333. /* INSPIRATION    : 'The Science Of Fractal Images.'
  334. /*
  335. /*   Copyright (c) Digital Equipment Corporation 1990  All rights reserved.
  336. /*   Copyright is claimed in the computer program and user interface thereof.
  337. /*
  338. /*   Digital Equipment Corporation cannot accept any responsibility for
  339. /*   use, misuse, or abuse of this software.
  340. /*
  341. /*****************************************************************************/
  342.  
  343. /*****************************************/
  344. /* CONFIGURE THIS SECTION AS REQUIRED... */
  345. /*****************************************/
  346.  
  347. #define FNTFILE         "fixed"
  348. #define PROGTITLE    "Xmntn"
  349.  
  350. /* The argument list processing structure... */
  351. #define NUMARGS    15
  352. struct opts    args[NUMARGS] = {
  353. {"-display",    "-ds", "",        "-display serverstring"},
  354. {"-foreground", "-fg", "white",        "-foreground colour"},
  355. {"-background", "-bg", "red",        "-background colour"},
  356. {"-textfg",      "-tf", "white",        "-textfg  colour"},
  357. {"-textbg",      "-tb", "blue",        "-textbg  colour"},
  358. {"-seacolour",  "-sc", "blue",        "-seacolour  colour"},
  359. {"-mntncolour", "-mc", "forestgreen",    "-mntncolour colour"},
  360. {"-numcolours", "-nc", "50",        "-numcolours integer"},
  361. {"-colours",      "-cl", "g",        "-colours r|g|b"},
  362. {"-fontfile",    "-fn", FNTFILE,        "-fontfile fontfile"},
  363. {"-H",        "-hg", "0.9",        "-H double"},
  364. {"-scale",     "-sl", "2.5",        "-scale double"},
  365. {"-level",      "-lv", "6",        "-level integer[3-~8]"},
  366. {"-xscale",    "-sx", "4",        "-xscale integer[1-4]"},
  367. {"-yscale",    "-sy", "2",        "-yscale integer[1-4]"},
  368. };
  369.  
  370. #define XOFFSET         0
  371. #define YOFFSET         0
  372. #define HEIGHT          5
  373.  
  374. /*****************************************/
  375. /* END OF CONFIGURATION SECTION...       */
  376. /*****************************************/
  377.  
  378. #define PNTS(i,px,py)    {pnts[(i)].x=(px);pnts[(i)].y=(py);}
  379. #define PIXELX(x,y)    (XOFFSET + (square - (x) + (y)) * xscale)
  380. #define    PIXELY(x,y)    (basey - YOFFSET - (square-(x)+square-(y))*yscale)
  381.  
  382. char    *progtitle = PROGTITLE;
  383. char    *bckgrnd   = BCKGRND;
  384. char    *iconfile  = ICONFILE;
  385.  
  386. extern int    screenwidth, screenheight;
  387. extern int    square;
  388. extern struct mntn {
  389.     double      **elevs;
  390.     int         **px;
  391.     int         **py;
  392. } mntndata;
  393. extern int    basey;
  394. extern Window    wndw;
  395. extern GC    maingc, seagc;
  396. extern Display    *dsply;
  397. extern long    mc;
  398.  
  399. int    xscale, yscale;
  400. SHAR_EOF
  401. if test 2490 -ne `wc -c < 'xmntn.h'`
  402. then
  403.     echo 'Shar: error transmitting 'xmntn.h' (should have been  2490 charcaters)'
  404. fi
  405. fi
  406. echo 'Shar: extracting 'xpt.c' ( 4720 characters)'
  407. if test -f 'xpt.c'
  408. then
  409.     echo "Shar: will not overwrite existing file 'xpt.c'"
  410. else
  411.     cat << \SHAR_EOF > 'xpt.c'
  412. /*****************************************************************************
  413. /* FILE        : xpt.c
  414. /* DATE        : August 25, 1989.
  415. /* AUTHOR    : Paul Sharpe @ DEC, Reading (OSCR-Europe).
  416. /* FUNCTION    : 'toolkit' of common functions.
  417. /*
  418. /*   Copyright (c) Digital Equipment Corporation 1990  All rights reserved.
  419. /*   Copyright is claimed in the computer program and user interface thereof.
  420. /*
  421. /*   Digital Equipment Corporation cannot accept any responsibility for
  422. /*   use, misuse, or abuse of this software.
  423. /*
  424. /*****************************************************************************/
  425.  
  426. #include <stdio.h>
  427.  
  428. #include <X11/Xlib.h>
  429. #include <X11/Xatom.h>
  430. #include <X11/Xutil.h>
  431.  
  432. #include "xpt.h"
  433.  
  434. char    *prog;
  435.  
  436. Display *
  437. xpt_open_display(str)
  438. char    *str;
  439. {
  440. extern char    *getenv();
  441. Display        *dsply;
  442.  
  443.     if (str == (char *)NULL || *str == '\0')
  444.     if ((str = getenv("DISPLAY")) == NULL)
  445.         str = DEFDSPLY;
  446.     dsply = XOpenDisplay(str);
  447.     if (dsply == (Display *)NULL) {
  448.     fprintf(stderr,"Sorry - can't open display '%s'\n",str);
  449.     exit(1);
  450.     }
  451.     return(dsply);
  452. }
  453.  
  454. xpt_getargs(args, numargs, argc,argv)
  455. struct    opts    args[];
  456. int        numargs;
  457. int        argc;
  458. char        *argv[];
  459. {
  460. int    i, gotflag = 0;
  461.  
  462.     prog = *argv;
  463.     while (--argc > 0) {
  464.     gotflag = 0;
  465.     if (**++argv != '-')
  466.         xpt_usage(args,numargs,"Value with no flag: %s",*argv);
  467.     for (i=0; i<numargs; i++) {
  468.         if (strncmp(*argv,args[i].flagstr,strlen(*argv))==0 ||
  469.             strcmp(*argv,args[i].aflagstr)==0) {
  470.  
  471. /* Have we already had a match for this argument string ? */
  472.         if (gotflag == 1)
  473.             xpt_usage(args,numargs,"Ambiguous flag: %s",*argv);
  474.         if (args[i].valstr != (char *)TRUE && args[i].valstr != (char *)FALSE) {
  475. /* We want an argument value from the next argv component. */
  476.             ++argv;
  477.             if (--argc <= 0)
  478.             xpt_usage(args,numargs,"Flag with no value: %s",*argv);
  479.             args[i].valstr = *argv;
  480.         }
  481.         gotflag = 1;
  482.         }
  483.     }
  484.     if (gotflag == 0)
  485.         xpt_usage(args,numargs,"Unknown flag: %s",*argv);
  486.     }
  487. }
  488.  
  489. xpt_usage(args,numargs, fmt,str)
  490. struct opts    args[];
  491. int        numargs;
  492. char        *fmt, *str;
  493. {
  494. int    i;
  495.  
  496.     fprintf(stderr,fmt,str);
  497.     fprintf(stderr,"\nUsage: %s \n",prog);
  498.     for (i=0; i<numargs; i++)
  499.     fprintf(stderr,"           %s\n",args[i].usage);
  500.     exit(1);
  501. }
  502.  
  503. Window
  504. xpt_window(dsply,parent,x,y,sx,sy,mask)
  505. Display    *dsply;
  506. Window    parent;
  507. int    x,y,sx,sy,mask;
  508. {
  509. Window            new;
  510. XSetWindowAttributes    attrs;
  511.  
  512.     attrs.event_mask = mask | ExposureMask;
  513.  
  514.     new = XCreateWindow(dsply,parent,x,y,sx,sy,2,DefaultDepth(dsply,DefaultScreen(dsply)),InputOutput,CopyFromParent,CWEventMask,&attrs);
  515.     if (new == (Window)NULL) {
  516.     fprintf(stderr,"FATAL: Couldn't create window.\n");
  517.     exit(1);
  518.     }
  519.     return(new);
  520. }
  521.  
  522. xpt_colour(dsply,name,clmap)
  523. Display        *dsply;
  524. char         *name;
  525. Colormap    clmap;
  526. {
  527. XColor        colour;
  528. static Colormap    defclmap = NULL;
  529.  
  530.     if (defclmap == (Colormap)NULL)
  531.     defclmap = DefaultColormapOfScreen(DefaultScreenOfDisplay(dsply));
  532.     if (clmap == (Colormap)NULL)
  533.     clmap = defclmap;
  534.  
  535.     if (XParseColor(dsply,clmap,name,&colour) == BadColor) {
  536.     fprintf(stderr,"WARNING: Failed to parse colour '%s'...\n",name);
  537.     return(0);
  538.     }
  539.     if (XAllocColor(dsply,clmap,&colour) == 0) {
  540.     fprintf(stderr,"FATAL: Failed to alloc colour '%s'...\n",name);
  541.     exit(1);
  542.     }
  543.     return(colour.pixel);
  544. }
  545.  
  546. xpt_windowcols(dsply,wndw,gc,clmap,bg,bd,tile)
  547. Display        *dsply;
  548. Window        wndw;
  549. GC        gc;
  550. Colormap    clmap;
  551. char        *bg, *bd, *tile;
  552. {
  553.     if (bg != (char *)NULL && *bg != '\0');
  554.     XSetWindowBackground(dsply,wndw,xpt_colour(dsply,bg,clmap));
  555.     if (bd != (char *)NULL && *bd != '\0');
  556.     XSetWindowBorder(dsply,wndw,xpt_colour(dsply,bd,clmap));
  557.     xpt_tile(dsply,wndw,gc,tile);
  558. }
  559.  
  560. /* Read a bitmap: if colour, convert to a pixmap; set to window background. */
  561. xpt_tile(dsply,wndw,gc,file)
  562. Display    *dsply;
  563. Window    wndw;
  564. GC    gc;
  565. char    *file;
  566. {
  567. int    h,w,x,y, depth;
  568. Pixmap    b, pix;
  569.  
  570.     if (file == (char *)NULL || *file == '\0')
  571.     return;
  572.     if (XReadBitmapFile(dsply,wndw,file,&w,&h,&b,&x,&y) != BitmapSuccess) {
  573.     fprintf(stderr,"WARNING: Can't load background bitmap '%s'.\n",file);
  574.     return;
  575.     }
  576.     if ((depth = DefaultDepth(dsply,DefaultScreen(dsply))) == 1)
  577.     XSetWindowBackgroundPixmap(dsply,wndw,b);
  578.     else {
  579.     pix = XCreatePixmap(dsply,wndw,w,h,depth);
  580.     XCopyPlane(dsply,b,pix,gc,0,0,w,h,0,0,1);
  581.     XSetWindowBackgroundPixmap(dsply,wndw,pix);
  582.     XFreePixmap(dsply,pix);
  583.     }
  584. }
  585.  
  586. xpt_icon(dsply,wndw,title,iconfile)
  587. Display    *dsply;
  588. Window    wndw;
  589. char    *title, *iconfile;
  590. {
  591. Pixmap    b;
  592. int    h,w,x,y;
  593. char    name[1][256];
  594.  
  595.     strcpy(name[0],title);
  596.     if (XReadBitmapFile(dsply,wndw,iconfile,&w,&h,&b,&x,&y) != BitmapSuccess)
  597.     fprintf(stderr,"WARNING: Can't load icon bitmap '%s'.\n",iconfile);
  598.     else
  599.     XSetStandardProperties(dsply,wndw,*name,*name,b,name,0,NULL);
  600. }
  601. SHAR_EOF
  602. if test 4720 -ne `wc -c < 'xpt.c'`
  603. then
  604.     echo 'Shar: error transmitting 'xpt.c' (should have been  4720 charcaters)'
  605. fi
  606. fi
  607. echo 'Shar: extracting 'gen_mntndata.c' ( 4450 characters)'
  608. if test -f 'gen_mntndata.c'
  609. then
  610.     echo "Shar: will not overwrite existing file 'gen_mntndata.c'"
  611. else
  612.     cat << \SHAR_EOF > 'gen_mntndata.c'
  613. /****************************************************************************
  614. /* FILE:    gen_mntndata.c
  615. /* AUTHOR:    Paul Sharpe @ DEC, OSCR_Europe, reading, England.
  616. /* DATE:    October 11, 1989.
  617. /* INSPIRATION:    'The Science Of factal Images'
  618. /*
  619. /*   Copyright (c) Digital Equipment Corporation 1990  All rights reserved.
  620. /*   Copyright is claimed in the computer program and user interface thereof.
  621. /*
  622. /*   Digital Equipment Corporation cannot accept any responsibility for
  623. /*   use, misuse, or abuse of this software.
  624. /*
  625. /****************************************************************************/
  626.  
  627. #include <stdio.h>
  628. #include <math.h>
  629.  
  630. #include "xpt.h"
  631.  
  632. #define F3(delta,x0,x1,x2)      ((x0+x1+x2)/3 + delta*Gauss())
  633. #define F4(delta,x0,x1,x2,x3)   ((x0+x1+x2+x3)/4 + delta*Gauss())
  634.  
  635. int        level;
  636. char        addition = 1;
  637. double        sigma, H;
  638. static int    Nrand, Arand;
  639. static double    GaussFac, GaussAdd;
  640. double        Gauss();
  641. static double    numer, denom; /* Replaces use of GaussFac for precision... */
  642.  
  643. gen_mntndata(elevs, square, top)
  644. double    **elevs, top;
  645. int    square;
  646. {
  647.     MidPointFM2D(elevs,level,sigma,H,addition,(int)time((long *)0));
  648.     scale(elevs, square, top);
  649. }
  650.  
  651. scale(elevs, square, top)
  652. double    **elevs;
  653. int    square;
  654. double    top;
  655. {
  656. register int    x,y;
  657. double        max = 0.0;
  658.  
  659.     for (x=0; x<square; x++)
  660.     for (y=0; y<square; y++)
  661.         if (elevs[x][y] > max)
  662.         max = elevs[x][y];
  663.     DEBUG(("Scaling: %f -> %f.\n",max,top));
  664.     if (max > 0.0)            /* Just in case summat goes wrong... */
  665.     for (x=0; x<square; x++)
  666.         for (y=0; y<square; y++)
  667.         elevs[x][y] = elevs[x][y]*top/max;
  668. }
  669.  
  670. /*==========================================================================
  671.  * Routines 'interpreted' from the code in 'The Science Of Fractal Images.'
  672.  *==========================================================================*/
  673. InitGauss(seed)
  674. int    seed;
  675. {
  676.     Nrand = 4;
  677.     Arand = (1<<31)-1;        /* random() gives results in [0,Arand] */
  678.  
  679.     GaussAdd = (double)sqrt((double)(3.0*Nrand));
  680. /* NB: GaussFac is no longer used: it loses too much precision!
  681.  *   GaussFac = (double)(2.0 * GaussAdd / ((double)Nrand * (double)Arand));
  682.  */
  683. /* NB: We have to do this, as we seem to loose too much precision in the method
  684.  *     laid out in 'The Scienc Of Fractal Images.'
  685.  */
  686.     numer = GaussAdd + GaussAdd;
  687.     denom = (double)((double)Nrand * (double)Arand);
  688.  
  689.     srandom(seed);
  690. }
  691.  
  692. double
  693. Gauss()
  694. {
  695. register int    i;
  696. register double    sum = 0;
  697. extern long    random();
  698.  
  699. /* See the above comment in InitGauss()... */
  700.     for (i=0; i<Nrand; i++)
  701.     sum += (double)random();
  702.     sum = numer*(sum/denom);
  703.     return(sum - GaussAdd);
  704. }
  705.  
  706. MidPointFM2D(X,maxlevel,sigma,H,addition,seed)
  707. double    **X;
  708. int    maxlevel;
  709. double    sigma;
  710. double    H;
  711. char    addition;
  712. int    seed;
  713. {
  714. register int    i, N, x,y, D,d;
  715. double        delta;
  716.  
  717.     InitGauss(seed);
  718.     N = 1<<maxlevel;
  719.     DEBUG(("MidPointFM2D: (Dim:%dx%d) (Sigma:%f) (H:%f).\n",N,N,sigma,H));
  720.  
  721.     delta = sigma;
  722.     X[0][0] = delta * Gauss();
  723.     X[0][N] = delta * Gauss();
  724.     X[N][0] = delta * Gauss();
  725.     X[N][N] = delta * Gauss();
  726.  
  727.     D = N;
  728.     d = N/2;
  729.  
  730.     for (i=0; i<maxlevel; i++) {
  731.  
  732. /* Going from Grid type I to Grid type II */
  733.     delta = delta * pow((double)0.5,(double)(0.5*H));
  734.     for (x=d; x<=N-d; x+=D)        /* Interpolate and offset points. */
  735.         for (y=d; y<=N-d; y+=D)
  736.         X[x][y] = F4(delta,X[x+d][y+d],X[x+d][y-d],X[x-d][y+d],X[x-d][y-d]);
  737.  
  738. /* Displace other points also if needed. */
  739.     if (addition == 1)
  740.         for (x=0; x<=N; x+=D)
  741.         for (y=0; y<=N; y+=D)
  742.             X[x][y] = X[x][y] + delta*Gauss();
  743.  
  744. /* Going from Grid type II to Grid type I */
  745.     delta = delta * pow(0.5,0.5*H);
  746. /* Interpolate and offset boundary grid points. */
  747.     for (x=d; x<=N-d; x+=D) {
  748.         X[x][0] = F3(delta,X[x+d][0],X[x-d][0],X[x][d]);
  749.         X[x][N] = F3(delta,X[x+d][N],X[x-d][N],X[x][N-d]);
  750.         X[0][x] = F3(delta,X[0][x+d],X[0][x-d],X[d][x]);
  751.         X[N][x] = F3(delta,X[N][x+d],X[N][x-d],X[N-d][x]);
  752.     }
  753.  
  754. /* Interpolate and offset interior grid points. */
  755.     for (x=d; x<=N-d; x+=D)
  756.         for (y=D; y<=N-d; y+=D)
  757.         X[x][y] = F4(delta,X[x][y+d],X[x][y-d],X[x+d][y],X[x-d][y]);
  758.  
  759.     for (x=D; x<=N-d; x+=D)
  760.         for (y=d; y<=N-d; y+=D)
  761.         X[x][y] = F4(delta,X[x][y+d],X[x][y-d],X[x+d][y],X[x-d][y]);
  762.  
  763. /* Displace other points also if needed. */
  764.     if (addition == 1) {
  765.         for (x=0; x<=N; x+=D)
  766.         for (y=0; y<=N; y+=D)
  767.             X[x][y] = X[x][y] + delta*Gauss();
  768.         for (x=d; x<=N-d; x+=D)
  769.         for (y=d; y<=N-d; y+=D)
  770.             X[x][y] = X[x][y] + delta*Gauss();
  771.     }
  772.  
  773.     D = D/2;
  774.     d = d/2;
  775.     }
  776. }
  777. SHAR_EOF
  778. if test 4450 -ne `wc -c < 'gen_mntndata.c'`
  779. then
  780.     echo 'Shar: error transmitting 'gen_mntndata.c' (should have been  4450 charcaters)'
  781. fi
  782. fi
  783. echo 'Shar: extracting 'cmn_mntncode.c' ( 9868 characters)'
  784. if test -f 'cmn_mntncode.c'
  785. then
  786.     echo "Shar: will not overwrite existing file 'cmn_mntncode.c'"
  787. else
  788.     cat << \SHAR_EOF > 'cmn_mntncode.c'
  789. /*****************************************************************************
  790. /* FILE        : cmn_mntncode.c
  791. /* AUTHOR    : Paul Sharpe @ DEC (OSCR-Europe, Reading, England).
  792. /* DATE        : July 20, 1989
  793. /* FUNCTION    : Common code in the mountain-generating programs.
  794. /* INSPIRATION    : 'The Science Of Fractal Images.'
  795. /*
  796. /*   Copyright (c) Digital Equipment Corporation 1990  All rights reserved.
  797. /*   Copyright is claimed in the computer program and user interface thereof.
  798. /*
  799. /*   Digital Equipment Corporation cannot accept any responsibility for
  800. /*   use, misuse, or abuse of this software.
  801. /*
  802. /*****************************************************************************/
  803.  
  804. #include <stdio.h>
  805. #include <math.h>
  806.  
  807. #include <X11/Xlib.h>
  808. #include <X11/Xatom.h>
  809. #include <X11/Xutil.h>
  810.  
  811. #include "xpt.h"
  812.  
  813. #define    RECALC        "New Mountains"
  814. #define QUIT        "Quit"
  815.  
  816. #define PNTS(i,px,py)    {pnts[(i)].x=(px);pnts[(i)].y=(py);}
  817.  
  818. #define ABS(x)        (((x)<0) ? -(x) : (x))
  819. #define SW(s)           (XTextWidth(fs,(s),strlen((s))))
  820.  
  821. int    screenwidth, screenheight;
  822. int    basey;
  823. int    square;
  824.  
  825. struct mntn {
  826.     double    **elevs;
  827.     int        **px;
  828.     int        **py;
  829. } mntndata;
  830. extern double    sigma, H;
  831. extern int    level;
  832.  
  833. extern char    *calloc();
  834. extern char    *bckgrnd, *progtitle, *iconfile;
  835.  
  836. Display        *dsply;        /* The display connected to. */
  837. Window        wndw;        /* The window in which to display */
  838. Window        hwndw,swndw, twndw, rwndw, qwndw;
  839. GC         maingc, mntngc,seagc, bttngc;
  840. unsigned long    mc;        /* Mountain colour(s?) */
  841. Colormap    clmap;        /* colourmap for colour display. */
  842. Pixmap        pntrbtm;
  843. Font        fnt;
  844. XFontStruct    *fs;
  845. int        wdth, hght;
  846. int        depth;        /* Display depth: no. of planes. */
  847. int        numcols;
  848. int        mntndist, scrndist;
  849.  
  850. static char    *titles[] = {"Brownian Motion","Mountains",
  851.                  "Paul Sharpe @ DEC"};
  852.  
  853. extern struct opts     args[];
  854.  
  855. init_cmn()
  856. {
  857.     sigma = atof(ARGS(11));    /* Scaling, or standard deviation. */
  858.     H = atof(ARGS(10));        /* Sets the fractal dimension. */
  859.     numcols = atoi(ARGS(7));
  860.     if ((level = atoi(ARGS(12))) < 1)
  861.     level = 1;
  862.     square = (1<<level) + 1;
  863.  
  864.     init_arrays();
  865. }
  866.  
  867. init_arrays()
  868. {
  869. register int    i;
  870.  
  871.     mntndata.elevs =(double **)calloc(square,(unsigned)sizeof(double *));
  872.     mntndata.px = (int **)calloc(square,(unsigned)sizeof(int *));
  873.     mntndata.py = (int **)calloc(square,(unsigned)sizeof(int *));
  874.     for (i=0; i<square; i++) {
  875.         mntndata.elevs[i] = (double *)calloc(square,(unsigned)sizeof(double));
  876.         mntndata.px[i] = (int *)calloc(square,(unsigned)sizeof(int));
  877.         mntndata.py[i] = (int *)calloc(square,(unsigned)sizeof(int));
  878.     }
  879. }
  880.  
  881. process_events()
  882. {
  883.     for(;;)
  884.     do_event();
  885. }
  886.  
  887. do_event()
  888. {
  889. XEvent        event;
  890.  
  891.     XNextEvent(dsply, &event);
  892.     switch (event.type) {
  893.     case Expose:
  894.     case GraphicsExpose:
  895.         if (event.xexpose.count == 0)
  896.             do_expose((XExposeEvent *)&event);
  897.         break;
  898.     case ButtonPress:    /* Get a new Dimension, and redisplay! */
  899.         do_bttn((XButtonPressedEvent *)&event);
  900.         break;
  901.     default:
  902.         break;
  903.     }
  904. }
  905.  
  906. do_expose(event)
  907. XExposeEvent    *event;
  908. {
  909.     if (event->window == qwndw)
  910.     XDrawString(dsply,qwndw,bttngc,2,fs->ascent+2,QUIT,strlen(QUIT));
  911.     if (event->window == rwndw)
  912.     XDrawString(dsply,rwndw,bttngc,2,fs->ascent+2,RECALC,strlen(RECALC));
  913.     if (event->window == swndw)
  914.     draw_scale();
  915.     if (event->window == hwndw)
  916.     draw_H();
  917.     if (event->window == twndw)
  918.     draw_titles();
  919.     if (event->window == wndw)
  920.     display();
  921. }
  922.  
  923. do_bttn(bttn)
  924. XButtonPressedEvent     *bttn;
  925. {
  926.     if (bttn->window == qwndw)
  927.     exit(1);
  928.     if (bttn->window == rwndw) {
  929.     gen_mntndata(mntndata.elevs,square, (double)(square-5));
  930.     elevs2coords();
  931.     XClearWindow(dsply,wndw);
  932.     display();
  933.     }
  934.     if (bttn->window == swndw) {
  935.     if (bttn->x < 300)
  936.         H = (double)((double)(bttn->x)/(double)100.0);
  937.     XClearWindow(dsply,swndw);
  938.     XClearWindow(dsply,hwndw);
  939.     draw_scale();
  940.     draw_H();
  941.     }
  942. }
  943.  
  944. draw_face(pnts, col)
  945. XPoint    pnts[];
  946. int    col;        /* Colour for the filled area. */
  947. {
  948. int        dy;
  949. static long    lastcol = -1;
  950.  
  951. /* Pseudo-shading determined by gradient of the face. */
  952.     if (col >= 0 && depth > 1 && numcols > 1) {
  953.     dy = (int)(pnts[1].y - pnts[3].y);
  954.     col = (pnts[0].y - pnts[2].y) + (20 - ABS(dy));
  955.         if (col >= numcols)
  956.         col = numcols - 1;
  957.     }
  958.     if (col < 0)
  959.     col = 0;
  960.  
  961. /* Try to speed up the display by only setting colours as necessary... */
  962.     if (col != lastcol) {
  963.     XSetForeground(dsply,mntngc,col);
  964.     lastcol = col;
  965.     }
  966.     XFillPolygon(dsply,wndw,mntngc,pnts,4,Nonconvex,CoordModeOrigin);
  967.  
  968. /* Draw the gridcolour lines around the filled quadilateral... */
  969.     if (numcols <= 1 || depth <= 1) {
  970.     pnts[4].x = pnts[0].x;
  971.     pnts[4].y = pnts[0].y;
  972.     XDrawLines(dsply,wndw,maingc,pnts,5,CoordModeOrigin);
  973.     }
  974. }
  975.  
  976. init_X()
  977. {
  978. int             x,y, len;
  979. Font            fnt;
  980. extern Window    xpt_window();
  981. extern Display  *xpt_open_display();
  982.  
  983.     dsply = xpt_open_display(ARGS(0));
  984.  
  985.     depth = DEFDEPTH(dsply);
  986.  
  987. /* If we have multi-planes, allow for some shading of the mountains. */
  988.     if (depth == 1 || numcols <= 1)
  989.     clmap = DefaultColormapOfScreen(DefaultScreenOfDisplay(dsply));
  990.     else {
  991.     clmap = XCreateColormap(dsply,ROOTWNDW(dsply),DefaultVisualOfScreen(DefaultScreenOfDisplay(dsply)),AllocNone);
  992.     set_cols(numcols);
  993.     }
  994.     set_GCs();
  995.  
  996.     x = screenwidth + 20;
  997.     y = screenheight + 20;
  998.     DEBUG(("Creating window: %dx%d.\n",x,y));
  999.     wndw  = xpt_window(dsply,ROOTWNDW(dsply),0,0,x,y,0);
  1000.     XSetWindowColormap(dsply,wndw,clmap);
  1001.     len = DisplayWidth(dsply,DefaultScreen(dsply));
  1002.     if (x > len)
  1003.     x = len;
  1004.     xpt_windowcols(dsply,wndw,maingc,clmap,ARGS(2),"white",bckgrnd);
  1005.  
  1006.     init_font();
  1007.  
  1008.     len = SW("0.000000");
  1009.     hwndw = xpt_window(dsply,wndw,x-len-20,10,len,hght+2,ButtonPressMask);
  1010.     xpt_windowcols(dsply,hwndw,bttngc,clmap,ARGS(4),ARGS(3),NULL);
  1011.     swndw = xpt_window(dsply,wndw,x-len-300-20,10,300,hght+2,ButtonPressMask);
  1012.     xpt_windowcols(dsply,swndw,bttngc,clmap,ARGS(4),ARGS(3),NULL);
  1013.     set_pointer();        /* Create a Pixmap holding the arrow pointer. */
  1014.  
  1015. /* BUTTON: Recalculate and draw new mountains. */
  1016.     len = SW(RECALC) + 2;
  1017.     rwndw = xpt_window(dsply,wndw,x-len-20,hght+20,len,hght+4,ButtonPressMask);
  1018.     xpt_windowcols(dsply,rwndw,bttngc,clmap,ARGS(4),ARGS(3),NULL);
  1019.  
  1020. /* BUTTON: Quit from mountain program. */
  1021.     len = SW(QUIT) + 2;
  1022.     qwndw = xpt_window(dsply,wndw,x-len-20,2*hght+30,len,hght+4,ButtonPressMask);
  1023.     xpt_windowcols(dsply,qwndw,bttngc,clmap,ARGS(4),ARGS(3),NULL);
  1024.  
  1025. /* Title block for the mountains, author etc. */
  1026.     len = XTextWidth(fs,titles[2],strlen(titles[2])) + 4;
  1027.     twndw = xpt_window(dsply,wndw,10,10,len,3*hght+4,ButtonPressMask);
  1028.     xpt_windowcols(dsply,twndw,bttngc,clmap,ARGS(4),ARGS(3),NULL);
  1029.  
  1030.     XMapSubwindows(dsply,wndw);
  1031.     XMapWindow(dsply,wndw);
  1032.  
  1033.     xpt_icon(dsply,wndw,progtitle,iconfile);
  1034. }
  1035.  
  1036. init_font()
  1037. {
  1038.     fnt = XLoadFont(dsply,ARGS(9));
  1039.     XSetFont(dsply,bttngc,fnt);
  1040.     fs = XQueryFont(dsply,fnt);
  1041.     wdth = fs->max_bounds.width;
  1042.     hght = 2 + fs->ascent + fs->descent;
  1043. }
  1044.  
  1045. set_GCs()
  1046. {
  1047.     maingc = XDefaultGC(dsply,DefaultScreen(dsply));
  1048.     XSetFunction(dsply,maingc,GXcopy);
  1049.     XSetPlaneMask(dsply,maingc,AllPlanes);
  1050.     XSetGraphicsExposures(dsply,maingc,True);
  1051.     XSetForeground(dsply, maingc, xpt_colour(dsply,ARGS(1),clmap));
  1052.     XSetBackground(dsply, maingc, xpt_colour(dsply,ARGS(2),clmap));
  1053.  
  1054.     bttngc = XCreateGC(dsply,ROOTWNDW(dsply),0,0);
  1055.     XCopyGC(dsply,maingc,-1L,bttngc);
  1056.     XSetForeground(dsply, bttngc, xpt_colour(dsply,ARGS(3),clmap));
  1057.     XSetBackground(dsply, bttngc, xpt_colour(dsply,ARGS(4),clmap));
  1058.  
  1059.     seagc = XCreateGC(dsply,ROOTWNDW(dsply),0,0);
  1060.     XCopyGC(dsply,maingc,-1L,seagc);
  1061.     XSetForeground(dsply, seagc, xpt_colour(dsply,ARGS(5),clmap));
  1062.  
  1063.     mntngc = XCreateGC(dsply,ROOTWNDW(dsply),0,0);
  1064.     XCopyGC(dsply,maingc,-1L,mntngc);
  1065.     XSetForeground(dsply, mntngc,(mc = xpt_colour(dsply,ARGS(6),clmap)));
  1066. }
  1067.  
  1068. set_cols(numcols)
  1069. int    numcols;
  1070. {
  1071. int        i, dc;
  1072. char        str[32], fmt[32];
  1073. extern char    *index();
  1074.  
  1075. /* Spread the colours out along the available spectrum... */
  1076.     sprintf(fmt,"#%s%s%s",(index(ARGS(8),'r')==NULL)?"0000":"%04x",
  1077.               (index(ARGS(8),'g')==NULL)?"0000":"%04x",
  1078.               (index(ARGS(8),'b')==NULL)?"0000":"%04x");
  1079.     if (numcols > 1) {
  1080.     dc = 65000/numcols;
  1081.     for (i=1; i<=numcols; i++) {
  1082.         sprintf(str,fmt,i*dc,i*dc,i*dc);
  1083.         xpt_colour(dsply,str,clmap);
  1084.     }
  1085.     }
  1086. }
  1087.  
  1088. draw_titles()
  1089. {
  1090. int    i, y;
  1091.  
  1092.     for (i=0; i<3; i++) {
  1093.     y = i*hght + fs->ascent + 1;
  1094.     XDrawString(dsply,twndw,bttngc,2,y,titles[i],strlen(titles[i]));
  1095.     }
  1096. }
  1097.  
  1098. draw_scale()
  1099. {
  1100. int    x, i;
  1101.  
  1102.     for (i=100; i<=200; i+=100) {
  1103.     XDrawLine(dsply,swndw,bttngc,i,0,i,5);
  1104.     XDrawLine(dsply,swndw,bttngc,i,hght,i,hght-5);
  1105.     }
  1106.     XDrawLine(dsply,swndw,bttngc,300,0,300,hght);
  1107.     x = (int)floor(H * (double)100.0) - (hght/2);
  1108.     XCopyArea(dsply,pntrbtm,swndw,bttngc,0,0,hght,hght,x,0);
  1109. }
  1110.  
  1111. draw_H()
  1112. {
  1113. char    str[16];
  1114.  
  1115.     sprintf(str,"%f",H);
  1116.     XDrawString(dsply,hwndw,bttngc,2,fs->ascent+2,str,strlen(str));
  1117. }
  1118.  
  1119. set_pointer()
  1120. {
  1121. XPoint    pnts[7];
  1122.  
  1123.     pntrbtm = XCreatePixmap(dsply,wndw,hght,hght,depth);
  1124.     if (pntrbtm == 0) {
  1125.     fprintf(stderr,"FATAL: Can't create pointer pixmap!\n");
  1126.     exit(2);
  1127.     }
  1128. /* Set the foreground to the normal button text background colour. */
  1129.     XSetForeground(dsply, bttngc, xpt_colour(dsply,ARGS(4),clmap));
  1130. /* Clear the Pixmap by filling it as a rectangle with the background colour. */
  1131.     XFillRectangle(dsply, pntrbtm,bttngc,0,0,hght,hght);
  1132. /* Reset the normal button text foreground colour. */
  1133.     XSetForeground(dsply, bttngc, xpt_colour(dsply,ARGS(3),clmap));
  1134.     pnts[0].x = hght/2;        pnts[0].y = 0;
  1135.     pnts[1].x = 0;        pnts[1].y = hght/2;
  1136.     pnts[2].x = hght/4;        pnts[2].y = pnts[1].y;
  1137.     pnts[3].x = pnts[2].x;    pnts[3].y = hght;
  1138.     pnts[4].x = 3*hght/4;    pnts[4].y = pnts[3].y;
  1139.     pnts[5].x = pnts[4].x;    pnts[5].y = pnts[1].y;
  1140.     pnts[6].x = hght;        pnts[6].y = pnts[5].y;
  1141.     XFillPolygon(dsply,pntrbtm,bttngc,pnts,7,Nonconvex,CoordModeOrigin);
  1142. }
  1143. SHAR_EOF
  1144. if test 9868 -ne `wc -c < 'cmn_mntncode.c'`
  1145. then
  1146.     echo 'Shar: error transmitting 'cmn_mntncode.c' (should have been  9868 charcaters)'
  1147. fi
  1148. fi
  1149. echo 'Shar: extracting 'xmntn.c' ( 5582 characters)'
  1150. if test -f 'xmntn.c'
  1151. then
  1152.     echo "Shar: will not overwrite existing file 'xmntn.c'"
  1153. else
  1154.     cat << \SHAR_EOF > 'xmntn.c'
  1155. /*****************************************************************************
  1156. /* FILE        : xmntn.c
  1157. /* AUTHOR    : Paul Sharpe @ DEC (OSCR-Europe, Reading, England).
  1158. /* DATE        : July 20, 1989
  1159. /* FUNCTION    : X-windows Fractal Brownian-Motion mountains.
  1160. /* INSPIRATION    : 'The Science Of Fractal Images.'
  1161. /*
  1162. /*   Copyright (c) Digital Equipment Corporation 1990  All rights reserved.
  1163. /*   Copyright is claimed in the computer program and user interface thereof.
  1164. /*
  1165. /*   Digital Equipment Corporation cannot accept any responsibility for
  1166. /*   use, misuse, or abuse of this software.
  1167. /*
  1168. /*****************************************************************************/
  1169.  
  1170. #include <stdio.h>
  1171. #include <math.h>
  1172.  
  1173. #include <X11/Xlib.h>
  1174. #include <X11/Xatom.h>
  1175. #include <X11/Xutil.h>
  1176.  
  1177. #include "xpt.h"
  1178. #include "xmntn.h"
  1179.  
  1180. main(argc,argv)
  1181. int    argc;
  1182. char    *argv[];
  1183. {
  1184.     xpt_getargs(args,NUMARGS,argc,argv);
  1185.     init();
  1186.     gen_mntndata(mntndata.elevs,square, (double)(yscale*square - 5));
  1187.     elevs2coords();
  1188.     process_events();            /* Main event-processing loop. */
  1189. }
  1190.  
  1191. init()
  1192. {
  1193.     init_cmn();
  1194.     if ((xscale = atoi(ARGS(13))) < 1)
  1195.         xscale = 1;
  1196.     if ((yscale = atoi(ARGS(14))) < 1)
  1197.         yscale = 1;
  1198.     screenwidth  = square*(xscale*2)+(XOFFSET*3);
  1199.     screenheight = square*yscale*3;
  1200.     basey = yscale*3*square;
  1201.     init_X();
  1202. }
  1203.  
  1204. elevs2coords()
  1205. {
  1206. register int    i,j, x,y, rowy;
  1207.  
  1208.     DEBUG(("Converting elevations to Y-coordinates..."));
  1209.  
  1210. /* To speed up, convert elevations for those points having the same Y-pixel
  1211.  * coordinate: i.e. those points on the diagonals.
  1212.  */
  1213.     for (i=0; i<square; i++) {
  1214.     rowy = PIXELY(i,0) - HEIGHT;
  1215.     for (j=0; j<=i; j++) {
  1216.         x = i - j;
  1217.         y = j;
  1218.         mntndata.px[x][y] = PIXELX(x,y);
  1219.         mntndata.py[x][y] = rowy - ((mntndata.elevs[x][y] <= (double)0.0)? 0:(int)floor(mntndata.elevs[x][y]));
  1220.     }
  1221.     }
  1222.     for (i=1; i<square; i++) {
  1223.     rowy = PIXELY(square-1,i) - HEIGHT;
  1224.     for (j=square-1; j>=i; j--) {
  1225.         x = j;
  1226.         y = i + square - j - 1;
  1227.         mntndata.px[x][y] = PIXELX(x,y);
  1228.         mntndata.py[x][y] = rowy - ((mntndata.elevs[x][y] <= (double)0.0)? 0:(int)floor(mntndata.elevs[x][y]));
  1229.     }
  1230.     }
  1231.     DEBUG(("DONE\n"));
  1232. }
  1233.  
  1234. display()
  1235. {
  1236.     draw_grid();
  1237.     draw_heights();
  1238. }
  1239.  
  1240. draw_grid()
  1241. {
  1242. register int    i;
  1243. static XPoint    pnts[6];
  1244.  
  1245. /* Colour the main grid ('the sea') polygon. */
  1246.     PNTS(0, PIXELX(square-1,square-1),    PIXELY(square-1,square-1));
  1247.     PNTS(1, PIXELX(square-1,0),        PIXELY(square-1,0));
  1248.     PNTS(2, pnts[1].x,            pnts[1].y - HEIGHT);
  1249.     PNTS(3, pnts[0].x,            PIXELY(0,0) - HEIGHT);
  1250.     PNTS(4, PIXELX(0,square-1),        pnts[2].y);
  1251.     PNTS(5, pnts[4].x,            pnts[1].y);
  1252.     XFillPolygon(dsply,wndw,seagc,pnts,6,Nonconvex,CoordModeOrigin);
  1253.     
  1254.     for (i=0; i<square; i++) {
  1255.     PNTS(0, PIXELX(square-1, i),    PIXELY(square-1, i));
  1256.     PNTS(1, pnts[0].x,        pnts[0].y - HEIGHT);
  1257.     PNTS(2, PIXELX(0, i),        PIXELY(0, i) - HEIGHT);
  1258.     XDrawLines(dsply,wndw,maingc,pnts,3,CoordModeOrigin);
  1259.  
  1260.     PNTS(0, PIXELX(i, square-1),    PIXELY(i, square-1));
  1261.     PNTS(1, pnts[0].x,        pnts[0].y - HEIGHT);
  1262.     PNTS(2, PIXELX(i, 0),        PIXELY(i, 0) - HEIGHT);
  1263.     XDrawLines(dsply,wndw,maingc,pnts,3,CoordModeOrigin);
  1264.     }
  1265.  
  1266. /* Bottom two lines of the block. */
  1267.     PNTS(0, PIXELX(0,square-1),        PIXELY(0,square-1));
  1268.     PNTS(1, PIXELX(square-1,square-1),    PIXELY(square-1,square-1));
  1269.     PNTS(2, PIXELX(square-1,0),        PIXELY(square-1,0));
  1270.     XDrawLines(dsply,wndw,maingc,pnts,3,CoordModeOrigin);
  1271. }
  1272.  
  1273. /******************************************************************************
  1274.  * Fill the quadilateral faces along lines parallel to a far edge.
  1275.  ******************************************************************************/
  1276. draw_heights()
  1277. {
  1278. register int    x,y;
  1279. static XPoint    pnts[4];
  1280.  
  1281.     for (x=0; x<square; x++)
  1282.     for (y=0; y<square; y++)
  1283.         if (x>0 && y>0)
  1284.         if (mntndata.elevs[x][y] > 0   || mntndata.elevs[x-1][y] > 0 ||
  1285.             mntndata.elevs[x][y-1] > 0 || mntndata.elevs[x-1][y-1] > 0){
  1286.             PNTS(0, mntndata.px[x][y],    mntndata.py[x][y]);
  1287.             PNTS(1, mntndata.px[x][y-1],  mntndata.py[x][y-1]);
  1288.             PNTS(2, mntndata.px[x-1][y-1],mntndata.py[x-1][y-1]);
  1289.             PNTS(3, mntndata.px[x-1][y],  mntndata.py[x-1][y]);
  1290.             draw_face(pnts,mc);
  1291.         }
  1292. }
  1293.  
  1294. #ifdef NOTUSED
  1295. /******************************************************************************
  1296.  * Fill the quadilateral faces along diagonal lines (parallel to the viewer).
  1297.  ******************************************************************************/
  1298. heights_by_diagonal()
  1299. {
  1300. register int    x,y;
  1301. static XPoint    pnts[5];
  1302.  
  1303. /* Top diagonal half of the complete square. */
  1304.     for (i=0; i<square; i++) {
  1305.     for (j=0; j<=i; j++) {
  1306.         if ((x = i - j) > 0 && (y = j) > 0)
  1307.         if (mntndata.elevs[x][y] > 0   || mntndata.elevs[x-1][y] > 0 ||
  1308.             mntndata.elevs[x][y-1] > 0 || mntndata.elevs[x-1][y-1] > 0){
  1309.             PNTS(0, mntndata.px[x][y],    mntndata.py[x][y]);
  1310.             PNTS(1, mntndata.px[x-1][y],  mntndata.py[x-1][y]);
  1311.             PNTS(2, mntndata.px[x-1][y-1],mntndata.py[x-1][y-1]);
  1312.             PNTS(3, mntndata.px[x][y],  mntndata.py[x][y]);
  1313.             draw_face(pnts,mc);
  1314.         }
  1315.     }
  1316.     }
  1317.  
  1318. /* Bottom diagonal half of the complete square. */
  1319.     for (i=1; i<square; i++) {
  1320.     for (j=square-1; j>=i; j--) {
  1321.         if ((x = j) > 0 && (y = i + square - j - 1) > 0)
  1322.         if (mntndata.elevs[x][y] > 0   || mntndata.elevs[x-1][y] > 0 ||
  1323.             mntndata.elevs[x][y-1] > 0 || mntndata.elevs[x-1][y-1] > 0){
  1324.             PNTS(0, mntndata.px[x][y],    mntndata.py[x][y]);
  1325.             PNTS(1, mntndata.px[x-1][y],  mntndata.py[x-1][y]);
  1326.             PNTS(2, mntndata.px[x-1][y-1],mntndata.py[x-1][y-1]);
  1327.             PNTS(3, mntndata.px[x][y],  mntndata.py[x][y]);
  1328.             draw_face(pnts,mc);
  1329.         }
  1330.     }
  1331.     }
  1332. }
  1333. #endif
  1334. SHAR_EOF
  1335. if test 5582 -ne `wc -c < 'xmntn.c'`
  1336. then
  1337.     echo 'Shar: error transmitting 'xmntn.c' (should have been  5582 charcaters)'
  1338. fi
  1339. fi
  1340. echo 'Shar: extracting 'xlmntn.c' ( 2897 characters)'
  1341. if test -f 'xlmntn.c'
  1342. then
  1343.     echo "Shar: will not overwrite existing file 'xlmntn.c'"
  1344. else
  1345.     cat << \SHAR_EOF > 'xlmntn.c'
  1346. /*****************************************************************************
  1347. /* FILE        : xlmntn.c
  1348. /* AUTHOR    : Paul Sharpe @ DEC (OSCR-Europe, Reading, England).
  1349. /* DATE        : July 20, 1989
  1350. /* FUNCTION    : X-windows Fractal Brownian-Motion mountains.
  1351. /* INSPIRATION    : 'The Science Of Fractal Images.'
  1352. /*
  1353. /*   Copyright (c) Digital Equipment Corporation 1990  All rights reserved.
  1354. /*   Copyright is claimed in the computer program and user interface thereof.
  1355. /*
  1356. /*   Digital Equipment Corporation cannot accept any responsibility for
  1357. /*   use, misuse, or abuse of this software.
  1358. /*
  1359. /*****************************************************************************/
  1360.  
  1361. #include <stdio.h>
  1362. #include <math.h>
  1363.  
  1364. #include <X11/Xlib.h>
  1365. #include <X11/Xatom.h>
  1366. #include <X11/Xutil.h>
  1367.  
  1368. #include "xpt.h"
  1369. #include "xlmntn.h"
  1370.  
  1371. main(argc,argv)
  1372. int    argc;
  1373. char    *argv[];
  1374. {
  1375.     xpt_getargs(args,NUMARGS,argc,argv);
  1376.     init();
  1377.     gen_mntndata(mntndata.elevs,square, (double)(square-5));
  1378.     elevs2coords();
  1379.     process_events();            /* Main event-processing loop. */
  1380. }
  1381.  
  1382. init()
  1383. {
  1384.     init_cmn();
  1385.     obsheight = atoi(ARGS(13));
  1386.     if ((mntndist = atoi(ARGS(13))) < 1)
  1387.     mntndist = 200;
  1388.     if ((scrndist = atoi(ARGS(14))) < 1)
  1389.     scrndist = 2000;
  1390.     screenwidth = square*scrndist/mntndist;
  1391.     screenheight= screenwidth;
  1392.     zeroy = screenheight - obsheight*scrndist/mntndist;
  1393.     init_X();
  1394. }
  1395.  
  1396. elevs2coords()
  1397. {
  1398. register int    x,y;
  1399.  
  1400.     basey = square;
  1401.     DEBUG(("Converting elevations to Y-coordinates...\n"));
  1402.  
  1403.     for (y=0; y<square; y++) {
  1404.     for (x=0; x<square; x++) {
  1405.         if (mntndata.elevs[x][y] <= 0.0)
  1406.         mntndata.elevs[x][y] = 0.000000;
  1407.         mntndata.px[x][y] = PIXELX(x,y);
  1408.         mntndata.py[x][y] = PIXELY(x,y,(int)floor(mntndata.elevs[x][y]));
  1409.     }
  1410.     }
  1411. }
  1412.  
  1413. display()
  1414. {
  1415.     draw_grid();
  1416.     draw_heights();
  1417. }
  1418.  
  1419. draw_grid()
  1420. {
  1421. XPoint    pnts[4];
  1422.  
  1423. /* Colour the main grid ('the sea') polygon. */
  1424.     PNTS(0, PIXELX(0,0),       PIXELY(0,0,0));
  1425.     PNTS(1, PIXELX(square,0),       PIXELY(square,0,0));
  1426.     PNTS(2, PIXELX(square,square), PIXELY(square,square,0));
  1427.     PNTS(3, PIXELX(0,square),       PIXELY(0,square,0));
  1428.     XFillPolygon(dsply,wndw,seagc,pnts,4,Nonconvex,CoordModeOrigin);
  1429. }
  1430.  
  1431. draw_heights()
  1432. {
  1433. register int    x,y;
  1434. XPoint        pnts[5];
  1435.  
  1436.     for (y=square-1; y>=0; y--) {
  1437.     for (x=0; x<square; x++) {
  1438.         if (y < square-1 && x > 0) {
  1439.         if (mntndata.elevs[x][y] > 0   || mntndata.elevs[x-1][y] > 0 ||
  1440.             mntndata.elevs[x][y+1] > 0 || mntndata.elevs[x-1][y+1] >0) {
  1441.  
  1442.             PNTS(0, mntndata.px[x][y],     mntndata.py[x][y]);
  1443.             PNTS(1, mntndata.px[x-1][y],   mntndata.py[x-1][y]);
  1444.             PNTS(2, mntndata.px[x-1][y+1], mntndata.py[x-1][y+1]);
  1445.             PNTS(3, mntndata.px[x][y+1]  , mntndata.py[x][y+1]);
  1446.             draw_face(pnts, mc);
  1447.  
  1448.             if (y == 0) {
  1449.             PNTS(2, mntndata.px[x-1][y], PIXELY(x-1,y,0));
  1450.             PNTS(3, mntndata.px[x][y]  , PIXELY(x  ,y,0));
  1451.             draw_face(pnts, -1);
  1452.             }
  1453.         } /* if elevs... */
  1454.         } /* if y */
  1455.     }
  1456.     }
  1457. }
  1458. SHAR_EOF
  1459. if test 2897 -ne `wc -c < 'xlmntn.c'`
  1460. then
  1461.     echo 'Shar: error transmitting 'xlmntn.c' (should have been  2897 charcaters)'
  1462. fi
  1463. fi
  1464. echo 'Shar: extracting 'bg.btm' ( 93 characters)'
  1465. if test -f 'bg.btm'
  1466. then
  1467.     echo "Shar: will not overwrite existing file 'bg.btm'"
  1468. else
  1469.     cat << \SHAR_EOF > 'bg.btm'
  1470. #define bg_width 4
  1471. #define bg_height 4
  1472. static char bg_bits[] = {
  1473.    0x05, 0x05, 0x05, 0x05};
  1474. SHAR_EOF
  1475. if test 93 -ne `wc -c < 'bg.btm'`
  1476. then
  1477.     echo 'Shar: error transmitting 'bg.btm' (should have been  93 charcaters)'
  1478. fi
  1479. fi
  1480. echo 'Shar: extracting 'mntn.btm' ( 3319 characters)'
  1481. if test -f 'mntn.btm'
  1482. then
  1483.     echo "Shar: will not overwrite existing file 'mntn.btm'"
  1484. else
  1485.     cat << \SHAR_EOF > 'mntn.btm'
  1486. #define mntn_width 64
  1487. #define mntn_height 64
  1488. #define mntn_x_hot -1
  1489. #define mntn_y_hot -1
  1490. static char mntn_bits[] = {
  1491.    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff,
  1492.    0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xff, 0x7f,
  1493.    0xfe, 0xff, 0x3f, 0xf0, 0xff, 0xff, 0x1f, 0x7f, 0xfe, 0xff, 0xbf, 0xf1,
  1494.    0xff, 0xff, 0x4f, 0x7c, 0xfe, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xe0, 0x7d,
  1495.    0xfe, 0xff, 0x6f, 0xfe, 0xff, 0x7f, 0xfe, 0x61, 0xfe, 0xff, 0xe3, 0xfc,
  1496.    0xff, 0x3f, 0xff, 0x5b, 0xfe, 0xff, 0xf8, 0xfd, 0xff, 0x1f, 0xff, 0x5f,
  1497.    0xfe, 0xff, 0xfe, 0xf9, 0xff, 0xdf, 0xff, 0x5f, 0xfe, 0x7f, 0xfe, 0xfb,
  1498.    0xff, 0xdf, 0xff, 0x47, 0xfe, 0x3f, 0xff, 0xf7, 0x7f, 0x1e, 0x00, 0x70,
  1499.    0xfe, 0x9f, 0xff, 0xf7, 0x7f, 0xfe, 0xff, 0x7f, 0xfe, 0xcf, 0xff, 0xef,
  1500.    0x3f, 0xfd, 0xff, 0x4f, 0xfe, 0x87, 0xff, 0xcf, 0x9f, 0xf9, 0xff, 0x0f,
  1501.    0xfe, 0x07, 0xff, 0x9f, 0xcf, 0xf3, 0xff, 0x27, 0xfe, 0x03, 0xfe, 0x3f,
  1502.    0xe7, 0xf7, 0xff, 0x73, 0xfe, 0x81, 0xf8, 0x7f, 0xf1, 0xf7, 0xff, 0x7b,
  1503.    0xfe, 0x40, 0xf1, 0x7f, 0xfc, 0xe7, 0xff, 0x79, 0x7e, 0xa0, 0xe2, 0xff,
  1504.    0xfe, 0x8f, 0xff, 0x7c, 0x7e, 0x40, 0xc5, 0xf8, 0xfc, 0xbf, 0x7f, 0x7c,
  1505.    0x3e, 0xa0, 0x0a, 0xf0, 0x79, 0x0c, 0x3f, 0x71, 0x3e, 0x50, 0x55, 0xe5,
  1506.    0x18, 0x00, 0x8e, 0x06, 0x1e, 0xa8, 0xaa, 0x0a, 0x00, 0x00, 0x44, 0x15,
  1507.    0x0e, 0x54, 0x54, 0x55, 0x15, 0x00, 0xa0, 0x2a, 0x06, 0x2a, 0xa8, 0xaa,
  1508.    0x0a, 0x00, 0x50, 0x55, 0x06, 0x55, 0x50, 0x55, 0x15, 0x00, 0xa0, 0x2a,
  1509.    0x82, 0x22, 0xa0, 0xa0, 0x2a, 0x00, 0x00, 0x55, 0x40, 0x55, 0x50, 0x51,
  1510.    0x55, 0x00, 0x00, 0x28, 0x80, 0x2a, 0xa8, 0xa2, 0xaa, 0x00, 0x00, 0x50,
  1511.    0x40, 0x11, 0x50, 0x01, 0x45, 0x01, 0x00, 0x20, 0x80, 0xa8, 0xa8, 0x8a,
  1512.    0xa2, 0x02, 0x00, 0x60, 0x40, 0x51, 0x14, 0x54, 0x15, 0x05, 0x00, 0x00,
  1513.    0xa0, 0x28, 0x2a, 0x8a, 0x22, 0x0a, 0x00, 0x00, 0x50, 0x14, 0x50, 0x15,
  1514.    0x55, 0x15, 0x00, 0x00, 0xa8, 0xa8, 0xa2, 0x2a, 0xaa, 0x2a, 0x00, 0x00,
  1515.    0x04, 0x54, 0x51, 0x55, 0x15, 0x50, 0x00, 0x00, 0x28, 0xaa, 0x00, 0x2a,
  1516.    0x0a, 0xa2, 0x00, 0x00, 0x44, 0x55, 0x00, 0x14, 0x15, 0x45, 0x01, 0x00,
  1517.    0xa8, 0x0a, 0x02, 0x2a, 0xaa, 0x8a, 0x02, 0x00, 0x44, 0x40, 0x11, 0x55,
  1518.    0x55, 0x05, 0x05, 0x00, 0x8a, 0x82, 0x00, 0x2a, 0xa8, 0xaa, 0x0a, 0x00,
  1519.    0x54, 0x51, 0x50, 0x55, 0x51, 0x11, 0x10, 0x00, 0x8a, 0x0a, 0x28, 0xa8,
  1520.    0x22, 0xa0, 0x22, 0x00, 0x44, 0x45, 0x54, 0x55, 0x05, 0x40, 0x45, 0x00,
  1521.    0x0a, 0x2a, 0xaa, 0xa0, 0x8a, 0x82, 0xaa, 0x00, 0x04, 0x55, 0x50, 0x41,
  1522.    0x55, 0x51, 0x05, 0x01, 0x22, 0xaa, 0x0a, 0xa2, 0xa8, 0x88, 0x2a, 0x02,
  1523.    0x54, 0x50, 0x41, 0x51, 0x51, 0x41, 0x54, 0x04, 0xaa, 0xaa, 0xaa, 0xaa,
  1524.    0xa2, 0x02, 0xaa, 0x0a, 0x54, 0x55, 0x55, 0x55, 0x55, 0x45, 0x40, 0x10,
  1525.    0x00, 0x00, 0x00, 0x00, 0x00, 0x8a, 0x8a, 0x2a, 0x00, 0x00, 0x00, 0x00,
  1526.    0x00, 0x45, 0x51, 0x51, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0x02, 0xa0, 0x22,
  1527.    0xfa, 0x7a, 0x01, 0xbd, 0x31, 0x55, 0x44, 0x55, 0x72, 0x72, 0xef, 0xb9,
  1528.    0x2e, 0x2a, 0x88, 0x22, 0xaa, 0x6a, 0xef, 0xb5, 0x3e, 0x15, 0x45, 0x51,
  1529.    0xaa, 0x6a, 0xef, 0xb5, 0x31, 0xaa, 0xa8, 0x22, 0xda, 0x5a, 0xef, 0xad,
  1530.    0x2f, 0x15, 0x54, 0x45, 0xda, 0x5a, 0xef, 0xad, 0x2f, 0x0a, 0x22, 0x02,
  1531.    0xfa, 0x3a, 0xef, 0x9d, 0x2e, 0x55, 0x01, 0x45, 0xfa, 0x7a, 0xef, 0xbd,
  1532.    0x31, 0xaa, 0xa8, 0x2a, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0x55, 0x55, 0x55,
  1533.    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  1534. SHAR_EOF
  1535. if test 3319 -ne `wc -c < 'mntn.btm'`
  1536. then
  1537.     echo 'Shar: error transmitting 'mntn.btm' (should have been  3319 charcaters)'
  1538. fi
  1539. fi
  1540.